home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Amiga Classic Collection
/
The Amiga Classic Collection - Disc 1.iso
/
Education
/
ED16-CrosswordCreator.DMS
/
ED16-CrosswordCreator.adf
/
Source
/
Cross.mod
< prev
next >
Wrap
Text File
|
1991-07-13
|
25KB
|
792 lines
(***************************************************************************
:Program. Cross
:Author. Jürgen Weinelt
:Address. Zur Kanzel 1, D-8783 Hammelburg, Germany
:Version. V4.1
:Copyright. Freeware; copy it, but don't sell it!
:Language. Modula-II
:Translator. M2Amiga V4.096d
:Imports. CPCDosIO
:Imports. CPCMenu
:Imports. CPCGlobal
:Imports. CPCPrint
:Imports. CPCRequesters
:Imports. CPCSleep
:Imports. CrossFont
:Imports. FileReq
:Contents. Program to create crossword puzzles.
:Contents. Features Intuition interface, filerequesters, and a special
:Contents. message data file to allow easy translation into any
:Contents. (human) language without changing the source code.
:History. V3.2 08-jan-91 first major release of M2 version on AMOK
:History. V3.3 06-feb-91 PAL/NTSC support added, released on fish 464
:History. V3.4 22-may-91 new compiler version 4.096d
:History. V3.5 28-jun-91 still struggling with compiler 4.096d
:History. V3.5A 09-jul-91 intermediate version, limited circulation
:History. V4.0 04-aug-91 many new features
:History. V4.1 15-aug-91 bug fixes, major release
**************************************************************************)
MODULE Cross;
IMPORT Arguments;
IMPORT Arts;
IMPORT Break;
IMPORT Conversions;
IMPORT CPCDosIO;
IMPORT CPCMenu;
IMPORT CPCGlobal;
IMPORT CPCPrint;
IMPORT CPCRequesters;
IMPORT CPCSleep;
IMPORT GraphicsL;
IMPORT InOut;
IMPORT IntuiIO;
IMPORT IntuitionD,IntuitionL;
IMPORT R;
IMPORT RandomNumber;
IMPORT String;
IMPORT SYSTEM;
CONST
progtitle="Cross V4.1 *** ©1991 by J.Weinelt";
underl ="---------------------------------";
spcs=" ";
limitbase=10;
lowerylimit=5;
(* upperylimit=35; !!! now VAR: PAL/NTSC support added 06-feb-91 !!! *)
(* defmsgline=27; ^^^ same as above ^^^ *)
defxsize=25;
defysize=25;
lowerxlimit=5;
upperxlimit=39;
maxRetry=5000;
TYPE
direction=(horizontal,vertical);
VAR
dir0: direction;
w,progname,tmp: CPCGlobal.String;
loop,word,wlen,x,y,cmp,num: INTEGER;
xloop,yloop,x0,y0,w0,len0,outerloop: INTEGER;
val0,tempH,tempV: INTEGER;
doH,booldummy: BOOLEAN;
limit,dummy,narg,msgline: INTEGER;
sec,micro: LONGINT;
msgmd: CPCDosIO.MsgMode;
scrname: CPCGlobal.LString;
ibase: IntuitionD.IntuitionBasePtr;
pal,lace: BOOLEAN;
upperylimit,defmsgline: INTEGER;
intuiHeight: INTEGER;
PROCEDURE TestH(VAR w: ARRAY OF CHAR; x,y,len,rlen,ref: INTEGER): INTEGER;
VAR
v{R.D6},loop{R.D7}: INTEGER;
BEGIN
IF (x+len<=CPCGlobal.xmax) AND (CPCGlobal.text[x-1,y]="\o") AND (CPCGlobal.text[x+len+1,y]="\o") THEN
v:=0;
FOR loop:=x TO x+len DO
IF (w[loop-x]=CPCGlobal.text[loop,y]) THEN
INC(v);
IF (CPCGlobal.text[loop-1,y]#"\o") OR (CPCGlobal.text[loop+1,y]#"\o") THEN
RETURN -1;
END;
ELSE
IF (CPCGlobal.text[loop,y-1]#"\o") OR (CPCGlobal.text[loop,y+1]#"\o") OR (CPCGlobal.text[loop,y]#"\o") THEN
RETURN -1;
END;
END;
END;
IF (v>ref) OR
((v=ref) AND (ref>0) AND ((len>rlen) OR
((len=rlen) AND (RandomNumber.RND(10)<2)))) THEN
RETURN v;
END;
END;
RETURN -1;
END TestH;
PROCEDURE TestV(VAR w: ARRAY OF CHAR; x,y,len,rlen,ref: INTEGER): INTEGER;
VAR
v{R.D6},loop{R.D7}: INTEGER;
BEGIN
IF (y+len<=CPCGlobal.ymax) AND (CPCGlobal.text[x,y-1]="\o") AND (CPCGlobal.text[x,y+len+1]="\o") THEN
v:=0;
FOR loop:=y TO y+len DO
IF (w[loop-y]=CPCGlobal.text[x,loop]) THEN
INC(v);
IF (CPCGlobal.text[x,loop-1]#"\o") OR (CPCGlobal.text[x,loop+1]#"\o") THEN
RETURN -1;
END;
ELSE
IF (CPCGlobal.text[x-1,loop]#"\o") OR (CPCGlobal.text[x+1,loop]#"\o") OR (CPCGlobal.text[x,loop]#"\o") THEN
RETURN -1;
END;
END;
END;
IF (v>ref) OR
((v=ref) AND (ref>0) AND ((len>rlen) OR
((len=rlen) AND (RandomNumber.RND(10)<2)))) THEN
RETURN v;
END;
END;
RETURN -1;
END TestV;
PROCEDURE Check(w: ARRAY OF CHAR): BOOLEAN;
VAR
loop: INTEGER;
BEGIN
FOR loop:=0 TO CPCGlobal.hori+CPCGlobal.vert DO
IF String.Compare(CPCGlobal.kwr[loop],w)=0 THEN
RETURN TRUE;
END;
END;
RETURN FALSE;
END Check;
PROCEDURE Place(a: ARRAY OF CHAR; x,y,len: INTEGER; d: direction);
VAR
loop: INTEGER;
BEGIN
String.Copy(CPCGlobal.kwr[CPCGlobal.hori+CPCGlobal.vert],a);
IF (d=horizontal) THEN
INC(CPCGlobal.hori);
FOR loop:=x+1 TO x+len+1 DO
CPCGlobal.text[loop,y+1]:=a[loop-x-1];
END;
CPCPrint.SmallPrintAtS(x,y,a);
ELSE
INC(CPCGlobal.vert);
FOR loop:=y+1 TO y+len+1 DO
CPCGlobal.text[x+1,loop]:=a[loop-y-1];
CPCPrint.SmallPrintAtC(x,loop-1,a[loop-y-1]);
END;
END;
END Place;
PROCEDURE Status;
VAR tmp: CPCGlobal.String;
dummy: BOOLEAN;
lx,ly: INTEGER;
cnt: LONGINT;
BEGIN
cnt:=0;
FOR lx:=1 TO CPCGlobal.xmax DO
FOR ly:=1 TO CPCGlobal.ymax DO
IF (CPCGlobal.text[lx,ly]#"\o") THEN
INC(cnt);
END;
END;
END;
CPCPrint.PrintAtS(CPCGlobal.stat,0,CPCGlobal.msg[26]);
Conversions.ValToStr(limit,FALSE,tmp,10,2,"0",dummy);
CPCPrint.Print(tmp,0);
CPCPrint.PrintAtS(CPCGlobal.stat,1,CPCGlobal.msg[27]);
Conversions.ValToStr(CPCGlobal.hori,FALSE,tmp,10,2,"0",dummy);
CPCPrint.Print(tmp,0);
CPCPrint.PrintAtS(CPCGlobal.stat,2,CPCGlobal.msg[28]);
Conversions.ValToStr(CPCGlobal.vert,FALSE,tmp,10,2,"0",dummy);
CPCPrint.Print(tmp,0);
CPCPrint.PrintAtS(CPCGlobal.stat,3,CPCGlobal.msg[29]);
Conversions.ValToStr(((cnt*100) DIV (LONGINT(CPCGlobal.xmax*CPCGlobal.ymax))),FALSE,tmp,10,2,"0",dummy);
CPCPrint.Print(tmp,0);
CPCPrint.SmallPrintAtS(60,10,"Cross Version 4.1");
CPCPrint.SmallPrintAtS(60,11,"Copyright (C) 1991 by \x80\x81\x82\x83\x84");
CPCPrint.SmallPrintAtS(60,12,"Cross is Freeware-");
CPCPrint.SmallPrintAtS(60,13," Copy it, but without profit!");
CPCPrint.SmallPrintAtS(60,15,"Don't look for Gadgets-");
CPCPrint.SmallPrintAtS(60,16," Version 4 uses Menus...");
END Status;
PROCEDURE PutSeedWord(x,y,size,maxsize: INTEGER; dir: direction): BOOLEAN;
VAR
word,wlen,counter: INTEGER;
w: CPCGlobal.String;
BEGIN
counter:=0;
REPEAT
word:=RandomNumber.RND(num)+1;
INC(counter);
UNTIL ((String.Length(CPCGlobal.words[word]^)>=size) AND
(String.Length(CPCGlobal.words[word]^)<=maxsize)) OR (counter>maxRetry);
IF counter<=maxRetry THEN
String.Copy(w,CPCGlobal.words[word]^);
wlen:=String.Length(w)-1;
IF dir=horizontal THEN
WHILE wlen+x>CPCGlobal.xmax DO DEC(x); END;
ELSE
WHILE wlen+y>CPCGlobal.ymax DO DEC(y); END;
END;
Place(w,x-1,y-1,wlen,dir);
String.Copy(CPCGlobal.words[word]^,"");
RETURN TRUE;
ELSE
RETURN FALSE;
END;
END PutSeedWord;
PROCEDURE NewCrossword;
VAR
lx,ly: INTEGER;
BEGIN
CPCSleep.SleepPointer;
FOR lx:=1 TO CPCGlobal.maxgrid DO
FOR ly:=1 TO CPCGlobal.maxgrid DO
CPCGlobal.text[lx,ly]:="\o";
END;
END;
num:=CPCDosIO.ReadWords(TRUE);
CPCGlobal.hori:=0;
CPCGlobal.vert:=0;
IntuitionL.ActivateWindow(SYSTEM.CAST(SYSTEM.ADDRESS,CPCGlobal.window));
IntuitionL.CurrentTime(SYSTEM.ADR(sec),SYSTEM.ADR(micro));
RandomNumber.PutSeed(sec);
CPCPrint.Cls;
CPCGlobal.search:=CPCGlobal.off; CPCGlobal.show:=CPCGlobal.on;
CPCMenu.ShowCommands;
limit:=limitbase;
Status;
CPCPrint.ShowAll;
CPCSleep.NormalPointer;
END NewCrossword;
PROCEDURE AskCommand;
VAR cmd: CHAR;
dummy,length,x,y: INTEGER;
bdum: BOOLEAN;
word: CPCGlobal.String;
dummyStr: ARRAY[0..1] OF CHAR;
imsg: IntuiIO.IntuiMsg;
menuID,itemID,subID: INTEGER;
txt: CPCGlobal.LString;
numstr: ARRAY[0..20] OF CHAR;
tmpxm,tmpym: INTEGER;
BEGIN
imsg:=IntuiIO.GetMessage(CPCGlobal.window);
IF imsg=IntuiIO.menuPick THEN
IntuiIO.GetMenu(CPCGlobal.window,menuID,itemID,subID);
CASE menuID OF
|0: CASE itemID OF
|0: (* new *)
CPCMenu.AllMenusOff;
IF CPCRequesters.YesOrNo(CPCGlobal.msg[18]) THEN
NewCrossword;
END;
CPCMenu.ShowCommands;
|1: (* load crossword *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCDosIO.LoadData;
CPCPrint.Cls;
CPCPrint.ShowAll;
Status;
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|2: (* load words *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
num:=CPCDosIO.ReadWords(FALSE);
CPCPrint.ClrLine(msgline);
Status;
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|3: (* save crossword *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCDosIO.SaveData;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|5: (* quit *)
CPCMenu.AllMenusOff;
IF CPCRequesters.YesOrNo(CPCGlobal.msg[50]) THEN
InOut.WriteLn; InOut.WriteString(CPCGlobal.msg[51]);
InOut.WriteLn; InOut.WriteLn;
Arts.Terminate;
END;
CPCMenu.ShowCommands;
|ELSE (* NOP *)
END;
|1: CASE itemID OF
|0: (* auto search mode toggle *)
IF (CPCGlobal.search=CPCGlobal.on) THEN
CPCGlobal.search:=CPCGlobal.off;
ELSE
CPCGlobal.search:=CPCGlobal.on;
END;
CPCMenu.ShowCommands;
|1: (* enter & place manually *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
IF (CPCGlobal.xmax>CPCGlobal.ymax) THEN
length:=CPCGlobal.xmax;
ELSE
length:=CPCGlobal.ymax;
END;
CPCSleep.NormalPointer;
CPCRequesters.InputLine(word,CPCGlobal.msg[40],
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
length);
CPCSleep.SleepPointer;
String.CapString(word);
IF String.Length(word)>0 THEN
IF Check(word) THEN
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[41],0);
ELSE
x:=1;
y:=1;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[42],0);
IntuiIO.AddIntuiMsg(CPCGlobal.window,IntuiIO.IntuiMsgSet{IntuiIO.mouseButtons});
CPCSleep.NormalPointer;
REPEAT
REPEAT
imsg:=IntuiIO.GetMessage(CPCGlobal.window);
UNTIL imsg=IntuiIO.mouseButtons;
x:=IntuiIO.GetMouse(CPCGlobal.window,IntuiIO.curentX);
y:=IntuiIO.GetMouse(CPCGlobal.window,IntuiIO.curentY);
CPCPrint.CharPos(x,y);
UNTIL (x>=0) AND (y>=0);
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
IF CPCRequesters.HoriOrVert(CPCGlobal.msg[43]) THEN
IF (TestH(word,x+1,y+1,String.Length(word)-1,0,-1)>=0) THEN
CPCSleep.SleepPointer;
Place(word,x,y,String.Length(word)-1,horizontal);
CPCPrint.ClrLine(msgline);
ELSE
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[44],0);
END;
ELSE
IF (TestV(word,x+1,y+1,String.Length(word)-1,0,-1)>=0) THEN
Place(word,x,y,String.Length(word)-1,vertical);
CPCPrint.ClrLine(msgline);
ELSE
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[44],0);
END;
END;
END;
END;
Status;
CPCPrint.ShowAll;
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|2: (* reset limit *)
CPCPrint.ClrLine(msgline);
limit:=limitbase;
CPCPrint.Print(CPCGlobal.msg[49],0);
Status;
|3: (* set size *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
String.Copy(txt,CPCGlobal.msg[88]);
Conversions.ValToStr(lowerxlimit,FALSE,numstr,10,0,"0",bdum);
String.Concat(txt,numstr);
String.Concat(txt,"...");
Conversions.ValToStr(upperxlimit,FALSE,numstr,10,0,"0",bdum);
String.Concat(txt,numstr);
String.Concat(txt,"):");
CPCSleep.NormalPointer;
tmpxm:=CPCRequesters.InputNum(txt,lowerxlimit,upperxlimit,
CPCGlobal.xmax,TRUE);
CPCSleep.SleepPointer;
IF tmpxm>0 THEN
String.Copy(txt,CPCGlobal.msg[89]);
Conversions.ValToStr(lowerylimit,FALSE,numstr,10,0,"0",bdum);
String.Concat(txt,numstr);
String.Concat(txt,"...");
Conversions.ValToStr(upperylimit,FALSE,numstr,10,0,"0",bdum);
String.Concat(txt,numstr);
String.Concat(txt,"):");
CPCSleep.NormalPointer;
tmpym:=CPCRequesters.InputNum(txt,lowerylimit,upperylimit,
CPCGlobal.ymax,TRUE);
CPCSleep.SleepPointer;
IF tmpym>0 THEN
CPCGlobal.xmax:=tmpxm;
CPCGlobal.ymax:=tmpym;
END;
END;
CPCPrint.Cls;
Status;
CPCPrint.ShowAll;
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|4: (* put seed words *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
IF (num>=4) THEN
cmp:=10;
IF (cmp>CPCGlobal.xmax-2) THEN
cmp:=CPCGlobal.xmax-2;
END;
IF PutSeedWord(1,1,cmp,CPCGlobal.xmax-2,horizontal) THEN
IF PutSeedWord(CPCGlobal.xmax,CPCGlobal.ymax,cmp,CPCGlobal.xmax-2,horizontal) THEN
cmp:=10;
IF (cmp>CPCGlobal.ymax-2) THEN
cmp:=CPCGlobal.ymax-2;
END;
IF PutSeedWord(CPCGlobal.xmax,1,cmp,CPCGlobal.ymax-2,vertical) THEN
IF PutSeedWord(1,CPCGlobal.ymax,cmp,CPCGlobal.ymax-2,vertical) THEN
(* NOP *)
END;
END;
END;
END;
END;
Status;
CPCPrint.ShowAll;
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|ELSE (* NOP *)
END;
|2: CASE itemID OF
|0: (* print crossword puzzle (plain) *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[46],0);
CPCDosIO.PrintPlainCross;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|1: (* print crossword puzzle (TeX) *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[46],0);
CPCDosIO.PrintTexCross;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|2: (* print crossword puzzle (fancy) *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[46],0);
CPCDosIO.PrintFancyCross;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|3: (* print crossword puzzle (Epson) *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[46],0);
CPCDosIO.PrintEpsonCross;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|4: (* print crossword solution *)
CPCMenu.AllMenusOff;
CPCSleep.SleepPointer;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[47],0);
CPCDosIO.PrintSolution;
CPCPrint.ClrLine(msgline);
CPCSleep.NormalPointer;
CPCMenu.ShowCommands;
|ELSE (* NOP *)
END;
|ELSE (* NOP *)
END;
END;
END AskCommand;
BEGIN
Break.InstallException;
scrname:=progtitle;
narg:=Arguments.NumArgs();
CPCGlobal.xmax:=-1;
CPCGlobal.ymax:=-1;
msgmd:=CPCDosIO.nonumbers;
ibase:=IntuitionL.intuitionBase;
IF (ibase^.firstScreen#NIL) THEN
(* try to figure out if this is a PAL or NTSC machine: *)
(* look at the "height" field of first screen and hope there's any *)
(* significance to this value *)
intuiHeight:=ibase^.firstScreen^.height;
IF (intuiHeight>=512) OR ((intuiHeight>=256) AND (intuiHeight<400)) THEN
(* this is pal resolution *)
upperylimit:=35;
defmsgline:=27;
pal:=TRUE;
ELSE
(* anything else means "not pal" *)
upperylimit:=25;
defmsgline:=20;
pal:=FALSE;
lace:=FALSE;
END;
ELSE
(* there's probably no use showing any error messages if there's no *)
(* screen present at all... i guess this will never be executed anyway *)
Arts.Terminate;
END;
IF NOT Arts.wbStarted THEN
FOR loop:=1 TO narg DO
Arguments.GetArg(loop,tmp,dummy);
IF (tmp[0]="-") THEN
tmp[0]:="0";
CASE tmp[1] OF
|"x","X": tmp[1]:="0";
CPCGlobal.xmax:=CPCDosIO.Value(tmp);
IF ((CPCGlobal.xmax<lowerxlimit) OR (CPCGlobal.xmax>upperxlimit) OR (ODD(CPCGlobal.xmax+1))) THEN
CPCGlobal.xmax:=-1;
InOut.WriteString("Illegal value for "+"XSIZE"+"; assuming default value\n");
END;
|"y","Y": tmp[1]:="0";
CPCGlobal.ymax:=CPCDosIO.Value(tmp);
IF ((CPCGlobal.ymax<lowerylimit) OR (CPCGlobal.ymax>upperylimit) OR (ODD(CPCGlobal.ymax+1))) THEN
CPCGlobal.ymax:=-1;
InOut.WriteString("Illegal value for "+"YSIZE"+"; assuming default value\n");
END;
|"d","D": msgmd:=CPCDosIO.numbers;
|ELSE
END;
END;
END;
(*-------------------- manual sizing if wbstarted... no longer needed! -----------
ELSE
InOut.WriteString("\n\nXSIZE("); InOut.WriteInt(lowerxlimit,0);
InOut.WriteString(".."); InOut.WriteInt(upperxlimit,0);
InOut.WriteString(")="); InOut.ReadInt(CPCGlobal.xmax);
IF ((CPCGlobal.xmax<lowerxlimit) OR (CPCGlobal.xmax>upperxlimit) OR
(ODD(CPCGlobal.xmax+1))) THEN
CPCGlobal.xmax:=-1;
InOut.WriteString("Illegal value for "+"XSIZE"+"; assuming default value\n");
END;
InOut.WriteString("\n\nYSIZE("); InOut.WriteInt(lowerylimit,0);
InOut.WriteString(".."); InOut.WriteInt(upperylimit,0);
InOut.WriteString(")="); InOut.ReadInt(CPCGlobal.ymax);
IF ((CPCGlobal.ymax<lowerylimit) OR (CPCGlobal.ymax>upperylimit) OR
(ODD(CPCGlobal.ymax+1))) THEN
CPCGlobal.ymax:=-1;
InOut.WriteString("Illegal value for "+"YSIZE"+"; assuming default value\n");
END;
--------------------------------------------------------------------------------*)
END;
Arguments.GetArg(0,progname,dummy);
IF (CPCGlobal.xmax=-1) THEN
CPCGlobal.xmax:=defxsize;
END;
IF (CPCGlobal.ymax=-1) THEN
CPCGlobal.ymax:=defysize;
END;
Arguments.GetArg(1,tmp,dummy);
IF (tmp[0]="?") THEN
InOut.WriteString("\n"+progtitle+"\n");
InOut.WriteString(underl);
InOut.WriteString("\nCopyright ©1991 by Jürgen Weinelt, Zur Kanzel 1, D-8783 Hammelburg, Germany.\n\n");
InOut.WriteString("Please Note: CPC is FREEWARE; you may copy it, but do not sell it!\n\n");
InOut.WriteString("Usage:\n");
InOut.WriteString(progname); InOut.WriteString(" [?] [-xXSIZE] [-yYSIZE] [-d]\n");
InOut.WriteString(" XSIZE: xsize in chars, ");
InOut.WriteInt(lowerxlimit,0); InOut.WriteString("<=x<=");
InOut.WriteInt(upperxlimit,0); InOut.WriteString(", default: ");
InOut.WriteInt(defxsize,0);
InOut.WriteString("\n YSIZE: ysize in chars, ");
InOut.WriteInt(lowerylimit,0); InOut.WriteString("<=y<=");
InOut.WriteInt(upperylimit,0); InOut.WriteString(", default: ");
InOut.WriteInt(defysize,0);
InOut.WriteString("\n -d: turn on message numbers (for word file debugging only!)\n");
InOut.WriteString("Please note: XSIZE and YSIZE must be odd!\n\n");
END;
IF (tmp[0]#"?") THEN
CPCDosIO.ReadMsg(msgmd);
IF pal THEN
CPCGlobal.screen:=IntuiIO.OpenScreen(scrname,0,0,640,256,1,IntuiIO.ScreenTypeSet{IntuiIO.hires});
ELSE
CPCGlobal.screen:=IntuiIO.OpenScreen(scrname,0,0,640,200,1,IntuiIO.ScreenTypeSet{IntuiIO.hires});
END;
Arts.Assert(CPCGlobal.screen#NIL,SYSTEM.ADR(CPCGlobal.msg[52]));
CPCGlobal.viewport:=IntuiIO.GetViewPort(CPCGlobal.screen);
GraphicsL.SetRGB4(CPCGlobal.viewport, 0, 0, 0, 0); (* screen background *)
GraphicsL.SetRGB4(CPCGlobal.viewport, 1, 15,15,15); (* screen foreground *)
GraphicsL.SetRGB4(CPCGlobal.viewport,17, 6, 6, 6); (* pointer color #1 *)
GraphicsL.SetRGB4(CPCGlobal.viewport,18, 11,11,11); (* pointer color #2 *)
GraphicsL.SetRGB4(CPCGlobal.viewport,19, 15,15,15); (* right. it's #3... *)
IF pal THEN
CPCGlobal.window:=IntuiIO.OpenWindow(scrname,0,0,640,256,
IntuiIO.WindowTypeSet{IntuiIO.activWindow,IntuiIO.backDrop,IntuiIO.borderless},CPCGlobal.screen);
ELSE
CPCGlobal.window:=IntuiIO.OpenWindow(scrname,0,0,640,200,
IntuiIO.WindowTypeSet{IntuiIO.activWindow,IntuiIO.backDrop,IntuiIO.borderless},CPCGlobal.screen);
END;
Arts.Assert(CPCGlobal.window#NIL,SYSTEM.ADR(CPCGlobal.msg[61]));
CPCGlobal.rastport:=IntuiIO.WindowRastPort(CPCGlobal.window);
CPCGlobal.topaz:=CPCGlobal.rastport^.font;
IntuiIO.AddIntuiMsg(CPCGlobal.window,IntuiIO.IntuiMsgSet{IntuiIO.menuPick});
CPCDosIO.InitCPCDosIO;
msgline:=defmsgline;
CPCPrint.Print("",1);
CPCPrint.Print(progtitle,1);
CPCPrint.Print(underl,2);
CPCPrint.Print("©1991 by",1);
CPCPrint.Print("Jürgen Weinelt",1);
CPCPrint.Print("Zur Kanzel 1",1);
CPCPrint.Print("D-8783 Hammelburg",1);
CPCPrint.Print("Germany",2);
CPCPrint.Print("Last changed: 15-Aug-91",2);
CPCPrint.Print("Please note: CPC is FREEWARE; you may copy it, but without making profit!",2);
CPCPrint.Print("This program was created using M2Amiga and the IntuitionReport and",1);
CPCPrint.Print("GraphicsReport support libraries. Thanks to A+L for these powerful tools.",2);
CPCPrint.Print("Special thanks to the ARP people for their file requester.",2);
CPCPrint.Print(CPCGlobal.msg[62],0);
NewCrossword;
(* main loop is "endless"; termination via Assert *)
(* in procedure AskCommand *)
LOOP
val0:=-1; len0:=0;
IF (CPCGlobal.show=CPCGlobal.off) THEN
CPCGlobal.show:=CPCGlobal.on;
CPCMenu.ShowCommands;
END;
AskCommand;
IF (CPCGlobal.search=CPCGlobal.on) THEN
CPCGlobal.show:=CPCGlobal.off;
FOR outerloop:=0 TO num DO
word:=outerloop;
String.Copy(w,CPCGlobal.words[word]^);
AskCommand;
IF (String.Length(w)>0) THEN
wlen:=String.Length(w)-1;
IF (wlen<limit) OR (wlen>limit+4) OR
(wlen+1<val0+val0) OR (wlen<=0) THEN
(* NOP *)
ELSIF Check(w) THEN
String.Copy(CPCGlobal.words[word]^,"");
ELSE
FOR xloop:=1 TO CPCGlobal.xmax DO
IF ((xloop MOD 2)=1) OR (limit<2) THEN
doH:=(xloop+wlen<=CPCGlobal.xmax);
FOR yloop:=1 TO CPCGlobal.ymax DO
IF ((yloop MOD 2)=1) OR (limit<2) THEN
tempH:=-1; tempV:=-1;
IF (doH) THEN
tempH:=TestH(w,xloop,yloop,wlen,len0,val0);
END;
IF (yloop+wlen<=CPCGlobal.ymax) THEN
tempV:=TestV(w,xloop,yloop,wlen,len0,val0);
END;
IF (tempH#-1) AND (tempH>=tempV) THEN
val0:=tempH; x0:=xloop; y0:=yloop;
w0:=word; dir0:=horizontal; len0:=wlen;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(w,0);
ELSIF (tempV#-1) THEN
val0:=tempV; x0:=xloop; y0:=yloop;
w0:=word; dir0:=vertical; len0:=wlen;
CPCPrint.ClrLine(msgline);
CPCPrint.Print(w,0);
END;
END;
END;
END;
END;
END;
END;
END;
IF (val0>=1) THEN
Place(CPCGlobal.words[w0]^,x0-1,y0-1,String.Length(CPCGlobal.words[w0]^)-1,dir0);
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.words[w0]^,0);
CPCPrint.Print(CPCGlobal.msg[64],0);
String.Copy(CPCGlobal.words[w0]^,"");
ELSE
IF (limit>1) THEN
DEC(limit,2);
ELSE
CPCPrint.ClrLine(msgline);
CPCPrint.Print(CPCGlobal.msg[65],0);
CPCGlobal.search:=CPCGlobal.off;
END;
END;
Status;
END;
END;
END;
CLOSE
(* window and screen are closed in module "CPCMenu", it can't be done here!!! *)
END Cross.